package io.renren.modules.canteens.dao;

import io.renren.common.dao.BaseDao;
import io.renren.modules.canteens.dto.SmallCanteenPurchaseDTO;
import io.renren.modules.canteens.entity.SmallCanteenPurchaseEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 小食堂采购表
 *
 * @author 翟文闯 619556390@QQ.com
 * @since 1.0.0 2019-11-22
 */
@Mapper
public interface SmallCanteenPurchaseDao extends BaseDao<SmallCanteenPurchaseEntity> {
    @Select("SELECT  sum(b.unit_price*b.arrival_num) as totalPrice,A.* FROM canteens_small_canteen_purchase A ,canteens_small_canteen_purchasemx B where a.small_canteen_purchase_id = b.small_canteen_purchase_id " +
            "and  A.status>=4 and A.canteen_id = '${canteenId}' ${createDate}  GROUP BY A.small_canteen_purchase_id  ${paging}")
    List<SmallCanteenPurchaseDTO> getOrderList(String  createDate, long canteenId, String paging);
    @Select("SELECT  sum(b.unit_price*b.arrival_num)as totalPrice,A.* FROM canteens_small_canteen_purchase A ,canteens_small_canteen_purchasemx B where a.small_canteen_purchase_id = b.small_canteen_purchase_id " +
            "and  A.status>=4 and A.canteen_id = '${canteenId}' ${createDate} ")
    SmallCanteenPurchaseDTO getOrdertotalMony(String  createDate,long canteenId);

    @Select(" SELECT  COUNT(*) as totalPage FROM canteens_small_canteen_purchase A where  A.status>=4  and  canteen_id = '${canteenId}' ${createDate}")
    SmallCanteenPurchaseDTO getTotalPage(String  createDate,long canteenId);
}